import bot from "../model/bot/amesu";
import browser, { tempDir } from "../model/browser/browser";
import func from "../model/func";
import skillAsay from "../model/skillAsay";
import { EffectType, SK_type, Sk_minType } from "../shared/interface";
import { MsgAction, Tpl_skillInfo } from "../shared/master/MsgAction";
import { style_default } from "../style/default";
export default async function (data: MsgAction,render?:boolean) {
    let d = data.data as Tpl_skillInfo;
    let typeName = d.type == SK_type.主动技能 ? '主动技能' : '被动技能';
    if (d.minType == Sk_minType.普通攻击) {
        typeName = '普通攻击';
    }
    func.roundNumbers(d)
    let png = await browser.render(tempDir.技能模板, {
        name: d.name,
        sk_type: typeName,
        useUp: d.useUp,
        score: d.score,
        cd: d.cd,
        show: d.show,
        desc: skillAsay(d),
        leve: d.leve,
        bg: func.random(1, 10),
        leve_bar: `${(d.leve.now / d.leve.max).toFixed(2)}%`
    })
    if(render){
        return new Promise((resolve)=>{
            resolve(png)
        })
    }else{
        bot.sendLocaImage(data.tolocation, png);
    }
}